<template>
  <div class="app-container clearfix">  
    <div v-if="businessData == undefined">
      <el-empty description="期权不存在"></el-empty>
    </div>
    <div v-else>
      <div>合约编码：{{businessData.symbol}}</div>
      <div>上市日期：{{businessData.market_date}}</div>
      <div>过期日期：{{businessData.expire_date}}</div>
      <div>持仓：{{businessData.position}}</div>
      <div>最后更新：{{businessData.updatedAt}}</div>
      <el-button type="info" @click="handleBackendButton()">返回</el-button>
      <div>
        
    <el-table
      key="realtimeList"
      v-loading="listLoading"
      :data="list"
      stripe
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="合约" width="200">
        <template slot-scope="{row}">
          <span >{{ row.symbol }}</span>
        </template>
      </el-table-column>
      <el-table-column label="日期" width="140">
        <template slot-scope="{row}">
          <span >{{ row.cycle }}</span>
        </template>
      </el-table-column>
      <el-table-column label="开盘价" width="100">
        <template slot-scope="{row}">
          <span >{{ row.close }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最低价" width="100">
        <template slot-scope="{row}">
          <span >{{ row.low }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最高价" width="100">
        <template slot-scope="{row}">
          <span >{{ row.high }}</span>
        </template>
      </el-table-column>
      <el-table-column label="收盘价" width="100">
        <template slot-scope="{row}">
          <span >{{ row.close }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交量" min-width="100">
        <template slot-scope="{row}">
          <span >{{ row.volume }}</span>
        </template>
      </el-table-column>
      <el-table-column label="成交额" min-width="100">
        <template slot-scope="{row}">
          <span >{{ row.amount }}</span>
        </template>
      </el-table-column>
      <el-table-column label="提交时间">
        <template slot-scope="{row}">
          <span >{{ row.createdAt }}</span>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination v-show="total>0" :total="total" :page.sync="filterForm.page" :limit.sync="filterForm.size" @pagination="getList" />
      </div>
    </div>
  </div>
</template>

<script>
import {getbusinessDetail} from '@/api/supply/business'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

import {getPolicyList} from '@/api/strategy/policy' 
import {getSignalList} from '@/api/strategy/signal' 



export default {
  name: 'businessDetails',
  components: { Pagination },
  directives: {  },
  filters: {
  },
  data() {
    return {
      total: 0,
      listLoading: false,
      list:[],
      filterForm: {
        page: 1,
        symbolType:1,
        size: 20,
        scale:1440,
        symbol:''
      },
      
      businessData:{}
    }
  },
  created() {
    let businessID = this.$route.query.businessID 
    businessID = parseInt(businessID)
    if(isNaN(businessID) == false){
      this.businessID = businessID
      this.getbusinessDetail()
    }
  },
  destroyed () {
  },
  methods: {
    getbusinessDetail:function(){
      let _this = this;
      getbusinessDetail({
        "businessID":this.businessID
      }).then((response) => {
        console.log("getList",response)
          if (response.code === 200) {
            _this.businessData = response.data
            _this.filterForm.symbol = _this.businessData.symbol
            _this.getList()
          } else {
            _this.$message({
              message: response.msg,
              type: 'error'
            })
          }
      })
    },
    getList:function(){
      let _this = this;
      console.log("期权",_this.filterForm)
      getQuotationList(_this.filterForm).then((response) => {
        console.log("getList",response)
          if (response.code === 200) {
            _this.list = response.data.list
            _this.total = response.data.total
          } else {
            _this.$message({
              message: response.msg,
              type: 'error'
            })
          }
      })
    },
    handleBackendButton:function(){
      
    }
  }
}
</script>
<style>
.filter { float: left; width: 160px; padding: 20px; min-height: 600px; }
.article { float: left; width: 800px; }
.article-item { width: 800px; height: 200px; margin-right: 25px; }
.article-item-text { float: left; width:600px; }
.article-item-icon { float: right; width:200px; height:150px; padding-left: 50px; }
.article-item-icon img { width:100%; height:100%; border-radius: 10px; }
</style>